package org.lennon.compent.aliyun.rocketmq.starter.sampleexemple.processor;

import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Message;
import org.lennon.compent.aliyun.rocketmq.client.consumer.AbstractRocketMQConsistentProcessor;
import org.lennon.compent.aliyun.rocketmq.client.exception.ConsumerMessageException;
import org.lennon.compent.aliyun.rocketmq.client.hook.RocketMQMessageHookRegister;
import org.lennon.compent.aliyun.rocketmq.client.hook.consumer.RocketMQProcessorHook;
import org.lennon.compent.aliyun.rocketmq.client.message.MessageBodyWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * <p>
 *
 * </p>
 *
 * @author lennon
 * @date 2019-11-09 9:36 AM
 */
@Component
public class TestProcessor extends AbstractRocketMQConsistentProcessor<TestDomain> {

	private static Logger logger = LoggerFactory.getLogger(TestProcessor.class);

	@Override
	public void processor(MessageBodyWrapper<TestDomain> messageBodyWrapper) throws ConsumerMessageException {
		logger.error("testProcessor.....");
	}

	public void initMethod() {
		RocketMQMessageHookRegister.register(this, new RocketMQProcessorHook(){
			@Override
			public void before(Message message, ConsumeContext consumeContext) {

			}

			@Override
			public void success(Message message, ConsumeContext consumeContext) {

			}

			@Override
			public void exception(Message message, ConsumeContext consumeContext, Throwable throwable) {

			}
		});
	}
}
